<%@ page import="com.example.yuntiku.entity.Curriculum" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2024-02-11
  Time: 10:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div id="kecheng">课程：
    <select class="select-style" name="one" onchange="selectTwo(this)">
        <c:forEach var="curriculum" items="${curriculums}">
            <option value="${curriculum.cid}" ${curriculum.cid == 2 ? 'selected' : ''}>${curriculum.csection}</option>
            <c:forEach var="curriculum1" items="${curriculum.children}">
                <option value="${curriculum1.cid}" ${curriculum1.cid == 2 ? 'selected' : ''}>----${curriculum1.csection}</option>
            </c:forEach>
        </c:forEach>
    </select>
</div>
<table id="table-two">

</table>

<script src="js/jquery-3.2.1.min.js"></script>
<script>
    function  selectTwo(select){
        // alert(select.value);
        $.getJSON("CurriculumTwoServlet",{"one":select.value},function (data){
            // alert(JSON.stringify(data))
            let table_two = $('#table-two');
            table_two.empty();//清空
            $.each(data,function (){
                table_two.append(`<tr>
                <td style="min-width: 20px;"><input onclick="selectSingle()" name="cartCheckBox" type="checkbox"/></td>
                <td style="min-width: 30px;"></td>
                <td style="min-width: 220px;">`+JSON.stringify(this.csection)+`</td>
                <td style="min-width: 188px;">1<span></span></td>
            </tr>`)
            })
        })
    }
</script>
</body>
</html>
